class Solution {
public:
    bool canJump(vector<int>& nums) {

        int n = nums.size();
        if(n == 1) return true;

        int access_pos = 0;

        for(int i = 0; i < n; i++){

            
            if(access_pos >= i){
                access_pos = max(access_pos+nums[i], access_pos);
            }
            else{
                return false;
            }

            if(access_pos >= n-1) return true;
        }

        return false;
    }
};